﻿<UserControl x:Class="BBInterfaceNET.Designer.Views.DesignerView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:conv="clr-namespace:BBInterfaceNET.Designer.Converters"
             xmlns:vm="clr-namespace:BBInterfaceNET.Designer.ViewModels"
             xmlns:v="clr-namespace:BBInterfaceNET.Designer.Views"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
        <conv:TabNameConverter x:Key="conv"/>
        <conv:DirtyConverter x:Key="conv2"/>
        <Style x:Key="tabButtonStyle" TargetType="{x:Type Button}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Border x:Name="border" BorderThickness="1">
                            <ContentPresenter VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                              Margin="{TemplateBinding Padding}"
                                              
                                              />
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter TargetName="border" Property="BorderBrush" Value="GoldenRod" />
                            </Trigger>
                            <Trigger Property="IsPressed" Value="True">
                                <Setter TargetName="border" Property="Background" Value="Yellow" />
                                <Setter TargetName="border" Property="BorderBrush" Value="GoldenRod" />
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <DataTemplate x:Key="ClosableTabItemTemplate">
            <DockPanel >
                <Button Command="{Binding Path=CloseCommand}"
                        Style="{StaticResource tabButtonStyle}"
        Content="X" Cursor="Hand" DockPanel.Dock="Right"
        Focusable="False" FontFamily="Courier" FontSize="9"
        FontWeight="Bold" Margin="5,1,0,0" Padding="0"
        VerticalContentAlignment="Bottom" Width="16" Height="16" />
                <ContentPresenter Content="{Binding Path=FilePath,Converter={StaticResource conv}}" VerticalAlignment="Center"
                                  DockPanel.Dock="Left"/>
                <ContentPresenter Content="{Binding Path=IsDirty,Converter={StaticResource conv2}}" VerticalAlignment="Center"
                                  DockPanel.Dock="Left"/>
            </DockPanel>
        </DataTemplate>
        
        <DataTemplate DataType="{x:Type vm:FileDesignerViewModel}">
            <v:FileDesignerView />
        </DataTemplate>

        <DataTemplate DataType="{x:Type vm:ImageDesignerViewModel}">
            <v:ImageDesignerView />
        </DataTemplate>
    </UserControl.Resources>
    <Grid Margin="2">
        <TabControl ItemsSource="{Binding Path=Files}" BorderThickness="0"
                    SelectedItem="{Binding Path=SelectedFile, Mode=TwoWay}"
                    ItemTemplate="{StaticResource ClosableTabItemTemplate}"
                    Background="Transparent" Padding="0"
                    >
            <TabControl.ItemContainerStyle>
                <Style TargetType="{x:Type TabItem}">
                    <Setter Property="Background" Value="WhiteSmoke"/>
                </Style>
            </TabControl.ItemContainerStyle>
        </TabControl>
    </Grid>
</UserControl>
